import addPassCheckService from  '../services/addPassCheckService';
import {Toast} from 'antd-mobile'

//添加
export const setAddPass=(data,callBack)=>{
		Toast.hide();
		Toast.loading("", 30, () => Toast.info("网络错误", 2));
		 addPassCheckService.verification(data).then(resultData => {
			Toast.hide();
			if(resultData.code==1000){
				let text = resultData.body;
				if(text.result==0){
				  Toast.info(text.failReson,1)
				  return;

				}else {
					verification(data,(res)=>{
						if(res.code==1000){
							callBack&&callBack()
						}
					})
				}
			}else {
				Toast.info(resultData.msg,1)
			}
		},()=>{
			Toast.hide(); 
            Toast.info("系统繁忙，请稍后再试");
		})
}
//检验
export const verification=(data,callBack)=>{
		Toast.hide();
		Toast.loading("", 30, () => Toast.info("网络错误", 2));
		addPassCheckService.addPass(data).then(resultData => {
			Toast.hide();
			if (resultData.code == 1000) {
				callBack&&callBack(resultData)
			} else {
				Toast.info(resultData.msg,1);
			}
		},()=>{
			Toast.hide(); 
            Toast.info("系统繁忙，请稍后再试");
		});
}

//删除
export const deletePass=(data,callBack)=>{
	Toast.hide();
	Toast.loading("", 30, () => Toast.info("网络错误", 2));
	addPassCheckService.deletePass(data).then(resultData => {
		Toast.hide();
		if (resultData.code == 1000) {
			callBack&&callBack(resultData)
		} else {
			Toast.info(resultData.msg,1);
		}
	},()=>{
		Toast.hide(); 
		Toast.info("系统繁忙，请稍后再试");
	});
}

//查询通行证
export const queryPass=(data,callBack)=>{
	Toast.hide();
	Toast.loading("", 30, () => Toast.info("网络错误", 2));
	addPassCheckService.queryPass(data).then(resultData => {
		Toast.hide();
		if (resultData.code == 1000) {
			callBack&&callBack(resultData.body)
		} else {
			Toast.info(resultData.msg,1);
		}
	},()=>{
		Toast.hide(); 
		Toast.info("系统繁忙，请稍后再试");
	});
}

